import type { BaseResponse } from '@/utils/request';
import { request } from '@/utils/request';
import Api from '@/core/permission/modules/sys/tag';

/**
 * 查询标签列表
 */
export function list(data: API.TagListParams) {
    return request<BaseResponse<API.TagList>>({
        url: Api.list,
        method: 'post',
        data
    })
}

/**
 * 删除标签
 */
export function remove(data: API.DelTagParmas) {
    return request({
        url: Api.delete,
        method: 'post',
        data,
        headers:{
            'Content-Type':'application/x-www-form-urlencoded'
        }
    })
}

/**
 * 修改或保存标签
 */
export function save(data: API.UpdateTagParams){
    return request({
        url: Api.save,
        method: 'post',
        data
    })
}

/**
 * 查询标签成员列表
 */
export function getTagAndUser(query: API.TagAndUserListParam){
    return request({
        url: Api.taguser,
        method: 'get',
        params: query
    })
}

/**
 * 查看部门人员树
 */
export function getDepartUserTree(query: { tenantId: string}){
    return request({
        url: Api.departUserTree,
        method: 'get',
        params: query
    })
}

/**
 * 添加成员到标签
 */
export function addUserToTag(data: API.AddUserToTagParam){
    return request({
        url: Api.batchSet,
        method: 'post',
        data,
        // headers:{
        //     'Content-Type':'application/json'
        // }
        
    })
}

/**
 * 根据标签id，查询当前已选择的人员id列表
 */
export function getUserIds(query: { tagId: string }){
    return request({
        url: Api.userIds,
        method: 'get',
        params: query
    })
}